load("@bazel_gazelle//:def.bzl", "gazelle")
load("@io_bazel_rules_go//go:def.bzl", "go_test")

gazelle(
    name = "update-repos",
    args = [
        "-from_file=go.mod",
        "-to_macro=repositories.bzl%go_repositories",
    ],
    command = "update-repos",
)

# gazelle:prefix chart_render_test
gazelle(name = "gazelle")

filegroup(
    name = "chart_definition",
    srcs = [
        "Chart.lock",
        "Chart.yaml",
    ],
)

filegroup(
    name = "chart_values",
    srcs = ["values.yaml"],
)

go_test(
    name = "chart_render_test_test",
    size = "small",
    srcs = ["chart_test.go"],
    data = [
        ":chart_definition",
        ":chart_values",
        "//templates:chart_helpers",
        "//templates:chart_notes",
        "//templates:chart_templates",
        "//testdata",
    ],
    deps = [
        "@com_github_gruntwork_io_terratest//modules/helm",
        "@com_github_gruntwork_io_terratest//modules/k8s",
        "@com_github_gruntwork_io_terratest//modules/logger",
        "@com_github_gruntwork_io_terratest//modules/random",
        "@com_github_stretchr_testify//assert",
        "@com_github_stretchr_testify//require",
        "@io_k8s_api//apps/v1:apps",
        "@io_k8s_api//rbac/v1:rbac",
        "@sh_helm_helm_v3//pkg/chart",
        "@sh_helm_helm_v3//pkg/chart/loader",
    ],
)

load("@bazel_bats//:rules.bzl", "bats_test")

bats_test(
  name = "chart_unit_tests",
  srcs = ["//test/unit:chart_unit_tests"],
  data = [
        ":chart_definition",
        ":chart_values",
        "//charts:chart_charts",
        "//templates:chart_helpers",
        "//templates:chart_notes",
        "//templates:chart_templates",
      "//test/unit:chart_unit_tests"
  ]
)
